<!-- CopyText.vue -->
<template>
  <div>
    <van-field v-model="text" label="Text" placeholder="Enter text to copy" />
    <van-button type="primary" @click="copyText">Copy Text</van-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { showToast } from 'vant';

const text = ref('');

const copyText = async () => {
  try {
    await navigator.clipboard.writeText(text.value);
    showToast('Text copied!');
  } catch (err) {
    showToast('Failed to copy text');
  }
};
</script>

<style scoped>
/* 可以在这里添加自定义样式 */
</style>
